Audio direct memory access (DMA) hardware typically loops over a buffer of physical/tangible memory in a cyclic fashion. Software reads a current position of a hardware DMA transfer within the cyclic buffer and reads or writes data to or from the buffer accordingly. Given that the buffer is cyclic, the software manages the data write wrap-around from the end of the buffer back to the beginning of the buffer either by exposing two individual transfers to a client application or by performing an interim data copy into physical memory on behalf of the client to facilitate the second transfer.
For example, a client application (“client”) such as a media player typically sets up audio streaming by requesting middleware to allocate a cyclic buffer of physical memory. Responsive to this request, a single block of virtual memory is mapped to a physical cyclical buffer in system memory. At this point, middleware manages all data I/O into the virtual memory block. Conventional memory management operations automatically transfer data written into the virtual memory block into corresponding addresses of the cyclic buffer in physical memory. When the client requests a pointer from the middleware to write data into the virtual memory beyond the end of the virtual memory, the middleware typically avoids buffer overflow by sending the client a pointer to a temporary buffer. After the client has written into the temporary buffer, the middleware transfers data bytes from the temporary buffer into the virtual memory block until the end of the virtual memory block is reached. Then, the middleware transfers the remaining data from the temporary buffer into the beginning of the virtual memory block. In this manner, the middleware manages wraparound data transfers to the cyclic buffer without buffer overflow. However, such buffer wrap-around management and additional data copies reduce system performance and increase the minimum achievable latency of an audio stream.